package com.qiantu.phone.ui.activity;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.qiantu.phone.R;
import com.qiantu.phone.app.AppActivity;
import com.qiantu.phone.ui.adapter.OpenPageSettingAdapter;
import com.qiantu.phone.utils.SPUtils;

import java.util.ArrayList;
import java.util.List;


public class OpenPageSettingActivity extends AppActivity {
    private RecyclerView list;
    private OpenPageSettingAdapter adapter;
    private Integer selectKey;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_home_page_setting;
    }

    @Override
    protected void initView() {
        list = findViewById(R.id.list);
        list.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter = new OpenPageSettingAdapter(getContext()){
            @Override
            public void onSelectChanged(Integer selected) {
                selectKey = selected;
            }
        };
        list.setAdapter(adapter);
    }

    @Override
    protected void initData() {
        List<Integer> strings = new ArrayList<>();
        strings.add(1);
        strings.add(2);
        strings.add(3);
        strings.add(4);
        adapter.setData(strings);
        Integer data = SPUtils.getInstance().getInt("openpagedata",1);
        selectKey = data;
        adapter.setSelected(data);
    }

    @Override
    public void onRightClick(View view) {
        SPUtils.getInstance().put("openpagedata",selectKey);
        finish();
    }
}
